﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Office.Interop.Excel;
using System.Reflection;
using GH.BLL;
using System.Data;

namespace GH.Web
{
    /// <summary>
    /// 报表区分
    /// </summary>
    public enum enumExcelOptiion
    {
        工会组织机构统计表 = 0,
        工会建家统计表 = 1,
        基层工会年度组织工作统计 = 2,
        各类员工入会率统计 = 3,
        聘用各类劳务人员入会率统计 = 4,
        各级工会组织专职工会干部工会干部培训统计 = 5,
        专职工会干部统计 = 6,
        基层工会年度法律援助工作统计 = 7,
        基层单位厂务公开民主管理工作统计表 = 8,
        劳动模范及获乐山市以上先进集体统计表 = 9,
        互助员工统计表 = 10,
        疗养计划表 = 11,
        疗养情况统计表 = 12
    }

    public partial class ExcelTest : BasePage.PageBase
    {
        public static string UnitRoot = System.Configuration.ConfigurationSettings.AppSettings["UnitRoot"];

        protected void Page_Load(object sender, EventArgs e)
        {
            System.Data.DataTable dtSource = null;
            enumExcelOptiion enumExcelOptiion = enumExcelOptiion.工会组织机构统计表;
            string TransFlg = Request.QueryString["TransFlg"].ToString();
            string strWhere = "  1=1";
            switch (TransFlg)
            {
                case "Organizations":
                    ReportOrganization bllReportOrganization = new ReportOrganization();
                    strWhere = "  1=1";
                    if (Request.QueryString["Action"].ToString() == "Summary")
                    {
                    }
                    else if (Request.QueryString["Action"].ToString() == "SELECT")
                    {
                        strWhere += " AND  工会组织机构统计表.单位=" + Request.QueryString["UnionID"].ToString();
                    }
                    dtSource = bllReportOrganization.GetList(strWhere).Tables[0];
                    enumExcelOptiion = enumExcelOptiion.工会组织机构统计表;
                    break;
                case "UnionBuiltHome":
                    BLL.UnionBuiltHome bllUnionBuiltHome = new GH.BLL.UnionBuiltHome();
                    strWhere = "  年份='" + Request.QueryString["TheDate"].ToString() + "'";
                    if (Request.QueryString["Action"].ToString() == "Summary")
                    {
                        //strWhere += " AND  会员基本信息.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    else if (Request.QueryString["Action"].ToString() == "SELECT")
                    {
                        strWhere += " AND  工会建家统计表.单位=" + Request.QueryString["UnionID"].ToString();
                    }
                    dtSource = bllUnionBuiltHome.GetList(strWhere).Tables[0];
                    enumExcelOptiion = enumExcelOptiion.工会建家统计表;
                    break;
                case "MemberShipRate":
                    BLL.MemberShipRate bllMemberShipRate = new GH.BLL.MemberShipRate();

                    strWhere = "  1=1";
                    if (Request.QueryString["Action"].ToString() == "Summary")
                    {

                    }
                    else if (Request.QueryString["Action"].ToString() == "SELECT")
                    {
                        strWhere += " AND  工会单位信息.ID=" + Request.QueryString["UnionID"].ToString();
                    }
                    dtSource = bllMemberShipRate.GetList(strWhere, Request.QueryString["TheDate"].ToString()).Tables[0];
                    enumExcelOptiion = enumExcelOptiion.各类员工入会率统计;
                    break;
                case "EmployMemberShipRate":


                    BLL.EmployMemberShipRate bllEmployMemberShipRate = new GH.BLL.EmployMemberShipRate();

                    strWhere = "  1=1";
                    if (Request.QueryString["Action"].ToString() == "Summary")
                    {

                    }
                    else if (Request.QueryString["Action"].ToString() == "SELECT")
                    {
                        strWhere += " AND  工会单位信息.ID=" + Request.QueryString["UnionID"].ToString();
                    }
                    dtSource = bllEmployMemberShipRate.GetList(strWhere, Request.QueryString["TheDate"].ToString()).Tables[0];
                    enumExcelOptiion = enumExcelOptiion.聘用各类劳务人员入会率统计;
                    break;

                case "LeaderTrain":

                    BLL.LeaderTrain bllLeaderTrain = new GH.BLL.LeaderTrain();
                    strWhere = "  ";
                    if (Request.QueryString["Action"].ToString() == "Summary")
                    { }
                    else if (Request.QueryString["Action"].ToString() == "SELECT")
                    {
                        strWhere += " AND  工会单位信息.ID=" + Request.QueryString["UnionID"].ToString();
                    }
                    dtSource = bllLeaderTrain.GetList2(strWhere, Request.QueryString["TheDate"].ToString()).Tables[0];
                    enumExcelOptiion = enumExcelOptiion.各级工会组织专职工会干部工会干部培训统计;
                    break;
                case "LeaderSummrise":

                    BLL.LeaderSummrise bllLeaderSummrise = new GH.BLL.LeaderSummrise();
                    strWhere = "  年份='" + Request.QueryString["TheDate"].ToString() + "'";
                    if (Request.QueryString["Action"].ToString() == "Summary")
                    { }
                    else if (Request.QueryString["Action"].ToString() == "SELECT")
                    {
                        strWhere += " And 专职工会干部统计表.单位=" + Request.QueryString["UnionID"].ToString();
                    }
                    dtSource = bllLeaderSummrise.GetList(strWhere).Tables[0];
                    enumExcelOptiion = enumExcelOptiion.专职工会干部统计;
                    break;
                case "LegalAid":
                    GH.BLL.LegalAid bllLegalAid = new GH.BLL.LegalAid();
                    strWhere = "  1=1";
                    if (Request.QueryString["Action"].ToString() == "Summary")
                    {

                        strWhere += " AND  工会年度法律援助统计表.年份='" + Request.QueryString["TheDate"].ToString() + "'";
                        dtSource = bllLegalAid.GetListSum(strWhere).Tables[0];
                    }
                    else if (Request.QueryString["Action"].ToString() == "SELECT")
                    {
                        strWhere += " AND  工会年度法律援助统计表.单位=" + Request.QueryString["UnionID"].ToString();
                        strWhere += " AND  工会年度法律援助统计表.年份='" + Request.QueryString["TheDate"].ToString() + "'";
                        dtSource = bllLegalAid.GetList(strWhere).Tables[0];
                    }
                    enumExcelOptiion = enumExcelOptiion.基层工会年度法律援助工作统计;
                    break;

                case "DemocraticManagement":
                    GH.BLL.DemocraticManagement bllDemocraticManagement = new GH.BLL.DemocraticManagement();
                    strWhere = "  1=1";
                    if (Request["Action"].ToString() == "Summary")
                    {
                        strWhere += " AND  厂务公开民主管理统计表.年份='" + Request.QueryString["TheDate"].ToString() + "'";
                        dtSource = bllDemocraticManagement.GetListSum(strWhere).Tables[0];

                    }
                    else if (Request["Action"].ToString() == "SELECT")
                    {
                        strWhere += " AND  厂务公开民主管理统计表.单位=" + Request.QueryString["UnionID"].ToString();
                        strWhere += " AND  厂务公开民主管理统计表.年份='" + Request.QueryString["TheDate"].ToString() + "'";
                        dtSource = bllDemocraticManagement.GetList(strWhere).Tables[0];
                    }

                    enumExcelOptiion = enumExcelOptiion.基层单位厂务公开民主管理工作统计表;
                    break;
                case "MutualMemberSumirise":
                    MutualMember bllMutualMember = new MutualMember();
                    strWhere = "  1=1";
                    if (Request.QueryString["Action"].ToString() == "Search")
                    {
                        string theUnionID = Request["theUnoinID"].ToString();
                        string theName = Request["theName"].ToString();

                        if (theUnionID != "0")
                        {
                            strWhere += " AND  互助员工统计表.单位=" + theUnionID;
                        }
                        if (theName.Trim().Length > 0)
                        {
                            strWhere += " AND  互助员工统计表.姓名 like '%" + theName.Trim() + "%'";
                        }
                    }
                    else if (Request.QueryString["Action"].ToString() == "SELECT")
                    {
                        strWhere += " AND  互助员工统计表.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    dtSource = bllMutualMember.GetList(strWhere).Tables[0];
                    enumExcelOptiion = enumExcelOptiion.互助员工统计表;

                    break;
                case "RecuperatePlanSumirise":

                    BLL.RecuperatePlan bllRecuperatePlan = new GH.BLL.RecuperatePlan();
                    string theDate = Session["SelectCurrentYear"].ToString();
                    strWhere = " 1=1";
                    if (Request.QueryString["Action"].ToString() == "Summary")
                    {
                        //strWhere += " AND  会员基本信息.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    else if (Request.QueryString["Action"].ToString() == "Action")
                    {
                        strWhere += " AND  员工疗养计划.单位=" + this.Session["UnionSelect"].ToString();
                    }

                    dtSource = bllRecuperatePlan.GetList(strWhere, theDate).Tables[0];
                    enumExcelOptiion = enumExcelOptiion.疗养计划表;
                    break;

                case "RecuperateCondation":

                    BLL.RecuperateCondation bllRecuperateCondation = new RecuperateCondation();
                    strWhere = "  年份='" + Session["SelectCurrentYear"].ToString() + "'";
                    if (Request.QueryString["Action"].ToString() == "Summary")
                    {
                        //strWhere += " AND  会员基本信息.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    else if (Request.QueryString["Action"].ToString() == "SELECT")
                    {
                        strWhere += " AND  疗养情况统计表.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    dtSource = bllRecuperateCondation.GetList(strWhere).Tables[0];
                    enumExcelOptiion = enumExcelOptiion.疗养情况统计表;
                    break;

                default:
                    break;
            }
            ExcelReportExport(dtSource, enumExcelOptiion);
        }


        public void ExcelReportExport(System.Data.DataTable dtSource, enumExcelOptiion enumExcelOptiion)
        {
            //Excel操作类
            ExcelOperate excelOperate = new ExcelOperate();
            //报表模板名称
            string strTempateFileName = string.Empty;
            string template_path = Server.MapPath("");//模板路径
            Application app = new Application();
            if (app == null)
            {
                return;
            }
            app.Visible = false;
            app.UserControl = true;
            Workbooks workbooks = app.Workbooks;
            #region MyRegion

            #endregion
            switch (enumExcelOptiion)
            {
                //1、工会工作-工会组织机构统计表
                case enumExcelOptiion.工会组织机构统计表:
                    strTempateFileName = "工会组织机构统计表.xls";
                    break;
                //2、工会工作-工会建家统计表	
                case enumExcelOptiion.工会建家统计表:
                    strTempateFileName = "工会建家统计表.xls";
                    break;

                //各类员工入会率统计
                case enumExcelOptiion.各类员工入会率统计:
                    strTempateFileName = "各类员工入会率统计.xls";
                    break;
                //聘用各类劳务人员入会率统计
                case enumExcelOptiion.聘用各类劳务人员入会率统计:
                    strTempateFileName = "聘用各类劳务人员入会率统计.xls";
                    break;
                //各级工会组织专职工会干部工会干部培训统计
                case enumExcelOptiion.各级工会组织专职工会干部工会干部培训统计:
                    strTempateFileName = "各级工会组织专职工会干部工会干部培训统计.xls";
                    break;
                //专职工会干部统计
                case enumExcelOptiion.专职工会干部统计:
                    strTempateFileName = "专职工会干部统计.xls";
                    break;
                //4、工会工作-基层工会年度法律援助工作统计
                case enumExcelOptiion.基层工会年度法律援助工作统计:
                    strTempateFileName = "基层工会年度法律援助工作统计.xls";
                    break;
                //5、工会工作-基层单位厂务公开民主管理工作统计表
                case enumExcelOptiion.基层单位厂务公开民主管理工作统计表:
                    strTempateFileName = "基层单位厂务公开民主管理工作统计表.xls";
                    break;
                //6、工会工作-劳动模范及获乐山市以上先进集体统计表
                case enumExcelOptiion.劳动模范及获乐山市以上先进集体统计表:
                    strTempateFileName = "劳动模范及获乐山市以上先进集体统计表.xls";
                    break;
                //1、职工福利-互助员工统计表	
                case enumExcelOptiion.互助员工统计表:
                    strTempateFileName = "互助员工统计表.xls";
                    break;
                //2、职工福利-疗（休）养计划表
                case enumExcelOptiion.疗养计划表:
                    strTempateFileName = "疗养计划表.xls";
                    break;
                //3、职工福利-疗养情况统计表
                case enumExcelOptiion.疗养情况统计表:
                    strTempateFileName = "疗养情况统计表.xls";
                    break;

            }
            _Workbook workbook = workbooks.Add(template_path + "\\" + strTempateFileName);//这里的Add方法里的参数就是模板的路径      
            Sheets sheets = workbook.Worksheets;
            _Worksheet worksheet = (_Worksheet)sheets.get_Item(1); //这里表示模板只有一个sheet表
            //_Worksheet Theworksheet = (_Worksheet)sheets.get_Item(2); //这里表示模板只有一个sheet表
            if (worksheet == null)
            {
                return;
            }

            switch (enumExcelOptiion)
            {
                //1、工会工作-工会组织机构统计表
                case enumExcelOptiion.工会组织机构统计表:
                    //插入格式   在第3行插入复制行
                    ((Range)(worksheet.Rows[3, System.Type.Missing])).Copy(System.Type.Missing);
                    for (int intIndex = 0; intIndex < dtSource.Rows.Count; intIndex++)
                    {
                        ((Range)(worksheet.Cells[3, 1])).EntireRow.Insert(1, System.Type.Missing);
                    }
                    //给报表赋值
                    for (int intIndex = 3; intIndex < dtSource.Rows.Count + 3; intIndex++)
                    {
                        //行(B3到I3) 内容从第3行开始
                        //序号  B⇒2	
                        worksheet.Cells[intIndex, 2] = intIndex - 2;
                        //单位	C⇒3
                        worksheet.Cells[intIndex, 3] = dtSource.Rows[intIndex - 3]["单位名称"].ToString();
                        //届数	D⇒4
                        worksheet.Cells[intIndex, 4] = dtSource.Rows[intIndex - 3]["届数"].ToString();
                        //主席	E⇒5
                        worksheet.Cells[intIndex, 5] = dtSource.Rows[intIndex - 3]["主席"].ToString();
                        //副主席 F⇒6
                        worksheet.Cells[intIndex, 6] = dtSource.Rows[intIndex - 3]["副主席"].ToString();
                        //委员名称 G⇒7	
                        worksheet.Cells[intIndex, 7] = dtSource.Rows[intIndex - 3]["委员姓名"].ToString();
                        //委员分工 H⇒8	
                        worksheet.Cells[intIndex, 8] = dtSource.Rows[intIndex - 3]["委员分工"].ToString();
                        //备注 I⇒9
                        worksheet.Cells[intIndex, 9] = dtSource.Rows[intIndex - 3]["备注"].ToString();
                    }
                    break;
                //2、工会工作-工会建家统计表	
                case enumExcelOptiion.工会建家统计表:

                    worksheet.Cells[1, 2] = UnitRoot + "工会建家情况统计表";
                    //插入年份

                    worksheet.Cells[2, 9] = Request.QueryString["TheDate"].ToString() + "年";


                    //插入格式   在第3行插入复制行
                    ((Range)(worksheet.Rows[4, System.Type.Missing])).Copy(System.Type.Missing);
                    for (int intIndex = 0; intIndex < dtSource.Rows.Count; intIndex++)
                    {
                        ((Range)(worksheet.Cells[4, 1])).EntireRow.Insert(1, System.Type.Missing);
                    }
                    //给报表赋值
                    for (int intIndex = 4; intIndex < dtSource.Rows.Count + 4; intIndex++)
                    {
                        //行(B3到I3) 内容从第3行开始
                        //序号  B⇒2	
                        // worksheet.Cells[intIndex, 2] = intIndex - 3;
                        //单位	B⇒2
                        worksheet.Cells[intIndex, 2] = dtSource.Rows[intIndex - 4]["单位名称"].ToString();
                        //职工之家名称	C⇒3
                        worksheet.Cells[intIndex, 3] = dtSource.Rows[intIndex - 4]["职工之家名称"].ToString();
                        //主席	D⇒4
                        worksheet.Cells[intIndex, 4] = dtSource.Rows[intIndex - 4]["工会主席"].ToString();
                        //现有等级名称 E⇒5
                        worksheet.Cells[intIndex, 5] = dtSource.Rows[intIndex - 4]["现有等级名称"].ToString();
                        //委员名称 F⇒6	
                        worksheet.Cells[intIndex, 6] = dtSource.Rows[intIndex - 4]["申报等级名称"].ToString();
                        //申报等级名称 G⇒7	
                        worksheet.Cells[intIndex, 7] = dtSource.Rows[intIndex - 4]["会员人数"].ToString();
                        //建成时间 H⇒8	
                        worksheet.Cells[intIndex, 8] = dtSource.Rows[intIndex - 4]["建成时间"].ToString();
                        //备注 I⇒9
                        worksheet.Cells[intIndex, 9] = dtSource.Rows[intIndex - 4]["备注"].ToString();
                    }

                    break;
                //各类员工入会率统计
                case enumExcelOptiion.各类员工入会率统计:


                    worksheet.Cells[1, 1] = Request.QueryString["TheDate"].ToString() + "年度工会组织建设统计表1—各类员工入会率统计";
                    //插入年份


                    //插入格式   在第3行插入复制行
                    ((Range)(worksheet.Rows[5, System.Type.Missing])).Copy(System.Type.Missing);
                    for (int intIndex = 0; intIndex < dtSource.Rows.Count; intIndex++)
                    {
                        ((Range)(worksheet.Cells[5, 1])).EntireRow.Insert(1, System.Type.Missing);
                    }
                    //给报表赋值
                    for (int intIndex = 5; intIndex < dtSource.Rows.Count + 5; intIndex++)
                    {
                        //行(B3到I3) 内容从第3行开始
                        //序号  A⇒1
                        worksheet.Cells[intIndex, 1] = intIndex - 4;
                        //单位	B⇒2
                        worksheet.Cells[intIndex, 2] = dtSource.Rows[intIndex - 5]["单位名称"].ToString();
                        //职工之家名称	C⇒3
                        worksheet.Cells[intIndex, 3] = dtSource.Rows[intIndex - 5]["各类员工合计"].ToString();
                        //主席	D⇒4
                        worksheet.Cells[intIndex, 4] = dtSource.Rows[intIndex - 5]["各类员工会员合计"].ToString();
                        //现有等级名称 E⇒5
                        worksheet.Cells[intIndex, 5] = GetPercent(dtSource.Rows[intIndex - 5]["各类员工入会率"]);
                        //委员名称 F⇒6	
                        worksheet.Cells[intIndex, 6] = dtSource.Rows[intIndex - 5]["省公司所有制员工数"].ToString();
                        //申报等级名称 G⇒7	
                        worksheet.Cells[intIndex, 7] = dtSource.Rows[intIndex - 5]["省公司所有制会员数"].ToString();
                        //建成时间 H⇒8	
                        worksheet.Cells[intIndex, 8] = GetPercent(dtSource.Rows[intIndex - 5]["同类员工入会率1"]);
                        //备注 I⇒9
                        worksheet.Cells[intIndex, 9] = dtSource.Rows[intIndex - 5]["省公司控股员工数"].ToString();
                        // J-10
                        worksheet.Cells[intIndex, 10] = dtSource.Rows[intIndex - 5]["省公司控股会员数"].ToString();
                        // K -11
                        worksheet.Cells[intIndex, 11] = GetPercent(dtSource.Rows[intIndex - 5]["同类员工入会率2"]);
                        // L-12
                        worksheet.Cells[intIndex, 12] = dtSource.Rows[intIndex - 5]["多经企业员工数"].ToString();
                        // M-13
                        worksheet.Cells[intIndex, 13] = dtSource.Rows[intIndex - 5]["多经企业员工会员数"].ToString();
                        // N-14
                        worksheet.Cells[intIndex, 14] = GetPercent(dtSource.Rows[intIndex - 5]["同类员工入会率3"]);
                        // O-15
                        worksheet.Cells[intIndex, 15] = dtSource.Rows[intIndex - 5]["聘用人员总数"].ToString();
                        // P-16
                        worksheet.Cells[intIndex, 16] = dtSource.Rows[intIndex - 5]["聘用会员总数1"].ToString();
                        // Q -17
                        worksheet.Cells[intIndex, 17] = GetPercent(dtSource.Rows[intIndex - 5]["同类员工入会率4"]);
                    }

                    break;
                //聘用各类劳务人员入会率统计
                case enumExcelOptiion.聘用各类劳务人员入会率统计:


                    worksheet.Cells[1, 1] = Request.QueryString["TheDate"].ToString() + "年度工会组织建设统计表2—聘用各类劳务人员入会率统计";
                    //插入年份


                    //插入格式   在第3行插入复制行
                    ((Range)(worksheet.Rows[5, System.Type.Missing])).Copy(System.Type.Missing);
                    for (int intIndex = 0; intIndex < dtSource.Rows.Count; intIndex++)
                    {
                        ((Range)(worksheet.Cells[5, 1])).EntireRow.Insert(1, System.Type.Missing);
                    }
                    //给报表赋值
                    for (int intIndex = 5; intIndex < dtSource.Rows.Count + 5; intIndex++)
                    {
                        //行(B3到I3) 内容从第3行开始
                        //序号  A⇒1
                        worksheet.Cells[intIndex, 1] = intIndex - 4;
                        //单位	B⇒2
                        worksheet.Cells[intIndex, 2] = dtSource.Rows[intIndex - 5]["单位名称"].ToString();
                        //各类员工合计	C⇒3
                        worksheet.Cells[intIndex, 3] = dtSource.Rows[intIndex - 5]["聘用人员总数"].ToString();
                        //各类员工会员合计	D⇒4
                        worksheet.Cells[intIndex, 4] = dtSource.Rows[intIndex - 5]["聘用各类会员总数"].ToString();
                        //各类员工入会率 E⇒5
                        worksheet.Cells[intIndex, 5] = GetPercent(dtSource.Rows[intIndex - 5]["同类员工入会率1"]);
                        //省公司所有制员工数 F⇒6	
                        worksheet.Cells[intIndex, 6] = dtSource.Rows[intIndex - 5]["电业局管辖电工数"].ToString();
                        //省公司所有制会员数 G⇒7	
                        worksheet.Cells[intIndex, 7] = dtSource.Rows[intIndex - 5]["电业局管辖电工会员数"].ToString();
                        //同类员工入会率 H⇒8	
                        worksheet.Cells[intIndex, 8] = GetPercent(dtSource.Rows[intIndex - 5]["同类员工入会率2"]);
                        //省公司控股员工数 I⇒9
                        worksheet.Cells[intIndex, 9] = dtSource.Rows[intIndex - 5]["省公司控股代电工数"].ToString();
                        // J-10
                        worksheet.Cells[intIndex, 10] = dtSource.Rows[intIndex - 5]["省公司控股会员数"].ToString();
                        // K -11
                        worksheet.Cells[intIndex, 11] = GetPercent(dtSource.Rows[intIndex - 5]["同类员工入会率3"]);
                        // L-12
                        worksheet.Cells[intIndex, 12] = dtSource.Rows[intIndex - 5]["本单位聘用人员数"].ToString();
                        // M-13
                        worksheet.Cells[intIndex, 13] = dtSource.Rows[intIndex - 5]["本单位聘用人员会员数"].ToString();
                        // N-14
                        worksheet.Cells[intIndex, 14] = GetPercent(dtSource.Rows[intIndex - 5]["同类员工入会率4"]);
                        // O-15
                        worksheet.Cells[intIndex, 15] = dtSource.Rows[intIndex - 5]["各单位聘用人员数"].ToString();
                        // P-16
                        worksheet.Cells[intIndex, 16] = dtSource.Rows[intIndex - 5]["各单位聘用会员数"].ToString();
                        // Q -17
                        worksheet.Cells[intIndex, 17] = GetPercent(dtSource.Rows[intIndex - 5]["同类员工入会率5"]);
                    }
                    break;
                //各级工会组织专职工会干部工会干部培训统计
                case enumExcelOptiion.各级工会组织专职工会干部工会干部培训统计:
                    worksheet.Cells[1, 1] = Request.QueryString["TheDate"].ToString() + "年度工会组织建设统计表3—各级工会组织、专职工会干部、工会干部培训统计 ";
                    //插入年份


                    //插入格式   在第5行插入复制行
                    ((Range)(worksheet.Rows[5, System.Type.Missing])).Copy(System.Type.Missing);
                    for (int intIndex = 0; intIndex < dtSource.Rows.Count; intIndex++)
                    {
                        ((Range)(worksheet.Cells[5, 1])).EntireRow.Insert(1, System.Type.Missing);
                    }
                    //给报表赋值
                    for (int intIndex = 5; intIndex < dtSource.Rows.Count + 5; intIndex++)
                    {
                        //行(B3到I3) 内容从第3行开始
                        //序号  A⇒1
                        worksheet.Cells[intIndex, 1] = intIndex - 4;
                        //单位	B⇒2
                        worksheet.Cells[intIndex, 2] = dtSource.Rows[intIndex - 5]["单位名称"].ToString();
                        //各类员工合计	C⇒3
                        worksheet.Cells[intIndex, 3] = dtSource.Rows[intIndex - 5]["所属基层分工会数"].ToString();
                        //各类员工会员合计	D⇒4
                        worksheet.Cells[intIndex, 4] = dtSource.Rows[intIndex - 5]["省公司所属企业分工会数"].ToString();
                        //各类员工入会率 E⇒5
                        worksheet.Cells[intIndex, 5] = dtSource.Rows[intIndex - 5]["省公司控股分工会数"].ToString();
                        //省公司所有制员工数 F⇒6	
                        worksheet.Cells[intIndex, 6] = dtSource.Rows[intIndex - 5]["分工会数"].ToString();
                        //省公司所有制会员数 G⇒7	
                        worksheet.Cells[intIndex, 7] = dtSource.Rows[intIndex - 5]["劳务人员分工会数"].ToString();
                        //同类员工入会率 H⇒8	
                        worksheet.Cells[intIndex, 8] = dtSource.Rows[intIndex - 5]["所属基层工会小组数"].ToString();
                        //省公司控股员工数 I⇒9
                        worksheet.Cells[intIndex, 9] = dtSource.Rows[intIndex - 5]["省公司所属工会小组数"].ToString();
                        // J-10
                        worksheet.Cells[intIndex, 10] = dtSource.Rows[intIndex - 5]["省公司控股工会小组数"].ToString();
                        // K -11
                        worksheet.Cells[intIndex, 11] = dtSource.Rows[intIndex - 5]["工会小组数"].ToString();
                        // L-12
                        worksheet.Cells[intIndex, 12] = dtSource.Rows[intIndex - 5]["劳务人员工会小组数"].ToString();
                        // M-13
                        worksheet.Cells[intIndex, 13] = dtSource.Rows[intIndex - 5]["专职工会干部数"].ToString();
                        // N-14
                        worksheet.Cells[intIndex, 14] = dtSource.Rows[intIndex - 5]["培训班次"].ToString();
                        // O-15
                        worksheet.Cells[intIndex, 15] = dtSource.Rows[intIndex - 5]["培训人次"].ToString();
                        // P-16
                        worksheet.Cells[intIndex, 16] = dtSource.Rows[intIndex - 5]["年度培训人数"].ToString();
                        // Q -17
                        worksheet.Cells[intIndex, 17] = GetPercent(dtSource.Rows[intIndex - 5]["年度培训率"]);
                    }
                    break;
                //专职工会干部统计
                case enumExcelOptiion.专职工会干部统计:

                    worksheet.Cells[1, 1] = Request.QueryString["TheDate"].ToString() + "年度工会组织建设统计表4—专职工会干部统计  ";
                    //插入年份


                    //插入格式   在第3行插入复制行
                    ((Range)(worksheet.Rows[3, System.Type.Missing])).Copy(System.Type.Missing);
                    for (int intIndex = 0; intIndex < dtSource.Rows.Count; intIndex++)
                    {
                        ((Range)(worksheet.Cells[3, 1])).EntireRow.Insert(1, System.Type.Missing);
                    }
                    //给报表赋值
                    for (int intIndex = 3; intIndex < dtSource.Rows.Count + 3; intIndex++)
                    {
                        //行(B3到I3) 内容从第3行开始
                        //序号  A⇒1
                        worksheet.Cells[intIndex, 1] = intIndex - 2;
                        //单位	B⇒2
                        worksheet.Cells[intIndex, 2] = dtSource.Rows[intIndex - 3]["单位名称"].ToString();
                        //各类员工合计	C⇒3
                        worksheet.Cells[intIndex, 3] = dtSource.Rows[intIndex - 3]["姓名"].ToString();
                        //各类员工会员合计	D⇒4
                        worksheet.Cells[intIndex, 4] = dtSource.Rows[intIndex - 3]["工作岗位及职务"].ToString();
                        //各类员工入会率 E⇒5
                        worksheet.Cells[intIndex, 5] = dtSource.Rows[intIndex - 3]["性别"].ToString();
                        //省公司所有制员工数 F⇒6	
                        worksheet.Cells[intIndex, 6] = dtSource.Rows[intIndex - 3]["出生年月"].ToString();
                        //省公司所有制会员数 G⇒7	
                        worksheet.Cells[intIndex, 7] = dtSource.Rows[intIndex - 3]["籍贯"].ToString();
                        //同类员工入会率 H⇒8	
                        worksheet.Cells[intIndex, 8] = dtSource.Rows[intIndex - 3]["民族"].ToString();
                        //省公司控股员工数 I⇒9
                        worksheet.Cells[intIndex, 9] = dtSource.Rows[intIndex - 3]["参加工作时间"].ToString();
                        // J-10
                        worksheet.Cells[intIndex, 10] = dtSource.Rows[intIndex - 3]["政治面貌名称"].ToString();
                        // K -11
                        worksheet.Cells[intIndex, 11] = dtSource.Rows[intIndex - 3]["技术职称名称"].ToString();
                        // L-12
                        worksheet.Cells[intIndex, 12] = dtSource.Rows[intIndex - 3]["文化程度名称"].ToString();
                        // M-13
                        worksheet.Cells[intIndex, 13] = dtSource.Rows[intIndex - 3]["工会工作年数"].ToString();

                    }

                    break;

                //4、工会工作-基层工会年度法律援助工作统计
                case enumExcelOptiion.基层工会年度法律援助工作统计:
                    string theUnionName = UnitRoot;
                    if (Request.QueryString["Action"].ToString() == "SELECT")
                    {
                        theUnionName = new GH.BLL.Union().GetModel(int.Parse(Request.QueryString["UnionID"].ToString())).单位名称;
                    }

                    worksheet.Cells[1, 2] = "表一、" + theUnionName + "  " + Request.QueryString["TheDate"].ToString() + "年度法律援助工作组织机构概况";

                    worksheet.Cells[7, 2] = "表二、" + theUnionName + "   " + Request.QueryString["TheDate"].ToString() + "年度开展法律援助工作情况表 ";


                    worksheet.Cells[4, 2] = GetYesNoName(dtSource.Rows[0]["厂级是否建立1"]);
                    worksheet.Cells[4, 3] = dtSource.Rows[0]["该委员会成员人数1"];
                    worksheet.Cells[4, 4] = dtSource.Rows[0]["调解员培训人员"];

                    worksheet.Cells[4, 5] = GetYesNoName(dtSource.Rows[0]["厂级是否建立2"]);
                    worksheet.Cells[4, 6] = dtSource.Rows[0]["该委员会成员人数2"];
                    worksheet.Cells[4, 7] = dtSource.Rows[0]["监督员培训人数"];
                    worksheet.Cells[4, 8] = GetYesNoName(dtSource.Rows[0]["厂级是否建立3"]);
                    worksheet.Cells[4, 9] = dtSource.Rows[0]["该委员会成员人数3"];




                    worksheet.Cells[10, 2] = dtSource.Rows[0]["劳动争议件数"];
                    worksheet.Cells[10, 3] = dtSource.Rows[0]["劳动争议职工人数"];
                    worksheet.Cells[10, 4] = dtSource.Rows[0]["调节劳动争议件数"];
                    worksheet.Cells[10, 5] = dtSource.Rows[0]["法律咨询人次"];
                    worksheet.Cells[10, 7] = dtSource.Rows[0]["诉讼案件数"];
                    worksheet.Cells[10, 8] = dtSource.Rows[0]["非诉讼案件数"];

                    break;





                    break;
                //5、工会工作-基层单位厂务公开民主管理工作统计表
                case enumExcelOptiion.基层单位厂务公开民主管理工作统计表:

                    string unionName = UnitRoot;
                    if (Request.QueryString["Action"].ToString() == "SELECT")
                    {
                        unionName = new GH.BLL.Union().GetModel(int.Parse(Request.QueryString["UnionID"].ToString())).单位名称;
                    }
                    worksheet.Cells[1, 2] = unionName + "   " + Request.QueryString["TheDate"].ToString() + "年度厂务公开民主管理工作统计表   ";
                    //插入年份
                    int count = 3;
                    worksheet.Cells[count, 5] = dtSource.Rows[0]["召开次数"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["审议企业重大事项"].ToString();
                    count++;

                    worksheet.Cells[count, 5] = dtSource.Rows[0]["征集提案"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["得到落实或回复1"].ToString();
                    count++;

                    worksheet.Cells[count, 5] = dtSource.Rows[0]["意见提议"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["得到落实或回复2"].ToString();
                    count++;

                    worksheet.Cells[count, 5] = dtSource.Rows[0]["举办职业代表培训"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["审议议案"].ToString();
                    count++;

                    worksheet.Cells[count, 5] = dtSource.Rows[0]["召开职代会联席会议"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["培训职工代表"].ToString();
                    count++;

                    worksheet.Cells[count, 5] = dtSource.Rows[0]["评议厂级干部次"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["评议中层领导干部次"].ToString();
                    count++;


                    worksheet.Cells[count, 5] = dtSource.Rows[0]["评议厂级干部人"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["评议中层领导干部人"].ToString();
                    count++;

                    worksheet.Cells[count, 5] = dtSource.Rows[0]["公开的事项"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["公开的满意度"].ToString();
                    count++;


                    worksheet.Cells[count, 5] = dtSource.Rows[0]["事物二级单位数"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["班组数"].ToString();
                    count++;


                    worksheet.Cells[count, 5] = dtSource.Rows[0]["开展巡视检查次数"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["参与讯巡视检查人数"].ToString();
                    count++;

                    worksheet.Cells[count, 5] = dtSource.Rows[0]["被检察单位或部门数"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["提出整改意见数"].ToString();
                    count++;

                    worksheet.Cells[count, 5] = dtSource.Rows[0]["整改意见落实数"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["职工代表满意度"].ToString();
                    count++;


                    worksheet.Cells[count, 5] = dtSource.Rows[0]["合同是否按揭续签"].ToString();
                    worksheet.Cells[count, 8] = GetYesNoName(dtSource.Rows[0]["是否签订女职工合同"].ToString());
                    count++;

                    worksheet.Cells[count, 5] = dtSource.Rows[0]["集体合同检查次数"].ToString();
                    worksheet.Cells[count, 8] = GetYesNoName(dtSource.Rows[0]["是否签订安全生产合同"].ToString());
                    count++;

                    worksheet.Cells[count, 5] = dtSource.Rows[0]["是否开展创建活动"].ToString();
                    worksheet.Cells[count, 8] = dtSource.Rows[0]["创建活动二级单位数"].ToString();
                    count++;

                    worksheet.Cells[count, 8] = GetYesNoName(dtSource.Rows[0]["是否获得企业称号"].ToString());
                    count++;



                    ////插入格式   在第3行插入复制行
                    //((Range)(worksheet.Rows[3, System.Type.Missing])).Copy(System.Type.Missing);
                    //for (int intIndex = 0; intIndex < dtSource.Rows.Count; intIndex++)
                    //{
                    //    ((Range)(worksheet.Cells[3, 1])).EntireRow.Insert(1, System.Type.Missing);
                    //}
                    ////给报表赋值
                    //for (int intIndex = 3; intIndex < dtSource.Rows.Count + 3; intIndex++)
                    //{
                    //    //行(B3到I3) 内容从第3行开始
                    //    //序号  A⇒1
                    //    worksheet.Cells[intIndex, 1] = intIndex - 2;
                    //    //单位	B⇒2
                    //    worksheet.Cells[intIndex, 2] = dtSource.Rows[intIndex - 3]["单位名称"].ToString();
                    //    //各类员工合计	C⇒3
                    //    worksheet.Cells[intIndex, 3] = dtSource.Rows[intIndex - 3]["姓名"].ToString();
                    //    //各类员工会员合计	D⇒4
                    //    worksheet.Cells[intIndex, 4] = dtSource.Rows[intIndex - 3]["工作岗位及职务"].ToString();
                    //    //各类员工入会率 E⇒5
                    //    worksheet.Cells[intIndex, 5] = dtSource.Rows[intIndex - 3]["性别"].ToString();
                    //    //省公司所有制员工数 F⇒6	
                    //    worksheet.Cells[intIndex, 6] = dtSource.Rows[intIndex - 3]["出生年月"].ToString();
                    //    //省公司所有制会员数 G⇒7	
                    //    worksheet.Cells[intIndex, 7] = dtSource.Rows[intIndex - 3]["籍贯"].ToString();
                    //    //同类员工入会率 H⇒8	
                    //    worksheet.Cells[intIndex, 8] = dtSource.Rows[intIndex - 3]["民族"].ToString();
                    //    //省公司控股员工数 I⇒9
                    //    worksheet.Cells[intIndex, 9] = dtSource.Rows[intIndex - 3]["参加工作时间"].ToString();
                    //    // J-10
                    //    worksheet.Cells[intIndex, 10] = dtSource.Rows[intIndex - 3]["政治面貌名称"].ToString();
                    //    // K -11
                    //    worksheet.Cells[intIndex, 11] = dtSource.Rows[intIndex - 3]["技术职称名称"].ToString();
                    //    // L-12
                    //    worksheet.Cells[intIndex, 12] = dtSource.Rows[intIndex - 3]["文化程度名称"].ToString();
                    //    // M-13
                    //    worksheet.Cells[intIndex, 13] = dtSource.Rows[intIndex - 3]["工会工作年数"].ToString();

                    //}

                    break;
                //6、工会工作-劳动模范及获乐山市以上先进集体统计表
                case enumExcelOptiion.劳动模范及获乐山市以上先进集体统计表:

                    break;
                //1、职工福利-互助员工统计表	
                case enumExcelOptiion.互助员工统计表:

                    //插入格式   在第3行插入复制行
                    ((Range)(worksheet.Rows[3, System.Type.Missing])).Copy(System.Type.Missing);
                    for (int intIndex = 0; intIndex < dtSource.Rows.Count; intIndex++)
                    {
                        ((Range)(worksheet.Cells[3, 1])).EntireRow.Insert(1, System.Type.Missing);
                    }
                    //给报表赋值
                    for (int intIndex = 3; intIndex < dtSource.Rows.Count + 3; intIndex++)
                    {
                        //行(B3到I3) 内容从第3行开始
                        //序号  B⇒2	
                        worksheet.Cells[intIndex, 2] = intIndex - 2;
                        //姓名	C⇒3
                        worksheet.Cells[intIndex, 3] = dtSource.Rows[intIndex - 3]["姓名"].ToString();
                        //性别	D⇒4
                        worksheet.Cells[intIndex, 4] = dtSource.Rows[intIndex - 3]["性别"].ToString();
                        //投保时间	E⇒5
                        worksheet.Cells[intIndex, 5] = dtSource.Rows[intIndex - 3]["投保时间"].ToString();
                        //投保金额 F⇒6
                        worksheet.Cells[intIndex, 6] = dtSource.Rows[intIndex - 3]["投保金额"].ToString();

                        //补助时间1 G⇒7	
                        worksheet.Cells[intIndex, 7] = dtSource.Rows[intIndex - 3]["补助时间1"].ToString();
                        //金额1 H⇒8	
                        worksheet.Cells[intIndex, 8] = dtSource.Rows[intIndex - 3]["金额1"].ToString();

                        //补助时间2 I⇒9
                        worksheet.Cells[intIndex, 9] = dtSource.Rows[intIndex - 3]["补助时间2"].ToString();
                        //金额2 J⇒10
                        worksheet.Cells[intIndex, 10] = dtSource.Rows[intIndex - 3]["金额2"].ToString();

                        //补助时间3 K⇒11
                        worksheet.Cells[intIndex, 11] = dtSource.Rows[intIndex - 3]["补助时间3"].ToString();
                        //金额3 L⇒12
                        worksheet.Cells[intIndex, 12] = dtSource.Rows[intIndex - 3]["金额3"].ToString();

                        //补助时间4 M⇒13
                        worksheet.Cells[intIndex, 13] = dtSource.Rows[intIndex - 3]["补助时间4"].ToString();
                        //金额4 N⇒14
                        worksheet.Cells[intIndex, 14] = dtSource.Rows[intIndex - 3]["金额4"].ToString();

                        //补助时间5 O⇒15
                        worksheet.Cells[intIndex, 15] = dtSource.Rows[intIndex - 3]["补助时间5"].ToString();
                        //金额5 P⇒16
                        worksheet.Cells[intIndex, 16] = dtSource.Rows[intIndex - 3]["金额5"].ToString();
                        //备注 Q⇒17
                        worksheet.Cells[intIndex, 17] = dtSource.Rows[intIndex - 3]["备注"].ToString();
                    }

                    break;
                //2、职工福利-疗（休）养计划表
                case enumExcelOptiion.疗养计划表:
                    int theDate = Convert.ToInt32(Session["SelectCurrentYear"]);
                    worksheet.Cells[1, 2] = theDate.ToString() + "年—" + (theDate + 4).ToString() + "年度职员工疗（休）养计划表";
                    worksheet.Cells[2, 5] = theDate.ToString() + "年计划";
                    worksheet.Cells[2, 6] = (theDate + 1).ToString() + "年计划";
                    worksheet.Cells[2, 7] = (theDate + 2).ToString() + "年计划";
                    worksheet.Cells[2, 8] = (theDate + 3).ToString() + "年计划";
                    worksheet.Cells[2, 9] = (theDate + 4).ToString() + "年计划";
                    //插入格式   在第3行插入复制行
                    ((Range)(worksheet.Rows[3, System.Type.Missing])).Copy(System.Type.Missing);
                    for (int intIndex = 0; intIndex < dtSource.Rows.Count; intIndex++)
                    {
                        ((Range)(worksheet.Cells[3, 1])).EntireRow.Insert(1, System.Type.Missing);
                    }
                    //给报表赋值
                    int signIndex = 0;


                    for (int intIndex = 3; intIndex < dtSource.Rows.Count + 3; intIndex++)
                    {
                        //行(B3到I3) 内容从第3行开始
                        //序号  B⇒2	
                        worksheet.Cells[intIndex, 2] = intIndex - 2;
                        //单位	C⇒3
                        worksheet.Cells[intIndex, 3] = dtSource.Rows[intIndex - 3]["单位名称"].ToString();
                        //届数	D⇒4
                        worksheet.Cells[intIndex, 4] = GetTotal(dtSource.Rows[intIndex - 3]["计划人数1"], dtSource.Rows[intIndex - 3]["计划人数2"], dtSource.Rows[intIndex - 3]["计划人数3"], dtSource.Rows[intIndex - 3]["计划人数4"], dtSource.Rows[intIndex - 3]["计划人数5"]);
                        //主席	E⇒5
                        worksheet.Cells[intIndex, 5] = dtSource.Rows[intIndex - 3]["计划人数1"].ToString();
                        //副主席 F⇒6
                        worksheet.Cells[intIndex, 6] = dtSource.Rows[intIndex - 3]["计划人数2"].ToString();
                        //委员名称 G⇒7	
                        worksheet.Cells[intIndex, 7] = dtSource.Rows[intIndex - 3]["计划人数3"].ToString();
                        //委员分工 H⇒8	
                        worksheet.Cells[intIndex, 8] = dtSource.Rows[intIndex - 3]["计划人数4"].ToString();
                        //备注 I⇒9
                        worksheet.Cells[intIndex, 9] = dtSource.Rows[intIndex - 3]["计划人数5"].ToString();

                        signIndex = intIndex;
                    }

                    int theTotal = 0;
                    int jh1Total = 0;
                    int jh2Total = 0;
                    int jh3Total = 0;
                    int jh4Total = 0;
                    int jh5Total = 0;
                    foreach (DataRow item in dtSource.Rows)
                    {
                        if (item["计划人数1"].ToString() != "")
                        {
                            jh1Total += Convert.ToInt32(item["计划人数1"]);
                        }
                        if (item["计划人数2"].ToString() != "")
                        {
                            jh2Total += Convert.ToInt32(item["计划人数2"]);
                        }
                        if (item["计划人数3"].ToString() != "")
                        {
                            jh3Total += Convert.ToInt32(item["计划人数3"]);
                        }
                        if (item["计划人数4"].ToString() != "")
                        {
                            jh4Total += Convert.ToInt32(item["计划人数4"]);
                        }
                        if (item["计划人数5"].ToString() != "")
                        {
                            jh5Total += Convert.ToInt32(item["计划人数5"]);
                        }
                    }
                    theTotal = jh1Total + jh2Total + jh3Total + jh4Total + jh5Total;
                    signIndex++;

                    //行(B3到I3) 内容从第3行开始
                    //序号  B⇒2	
                    worksheet.Cells[signIndex, 2] = signIndex - 2;
                    //单位	C⇒3
                    worksheet.Cells[signIndex, 3] = "合计";
                    //届数	D⇒4
                    worksheet.Cells[signIndex, 4] = theTotal;
                    //主席	E⇒5
                    worksheet.Cells[signIndex, 5] = jh1Total;
                    //副主席 F⇒6
                    worksheet.Cells[signIndex, 6] = jh2Total;
                    //委员名称 G⇒7	
                    worksheet.Cells[signIndex, 7] = jh3Total;
                    //委员分工 H⇒8	
                    worksheet.Cells[signIndex, 8] = jh4Total;
                    //备注 I⇒9
                    worksheet.Cells[signIndex, 9] = jh5Total;

                    break;
                //3、职工福利-疗养情况统计表
                case enumExcelOptiion.疗养情况统计表:

                    int theCondationDate = Convert.ToInt32(Session["SelectCurrentYear"]);
                    if (Request.QueryString["Action"].ToString() == "Summary")
                    {
                        worksheet.Cells[2, 2] = "单位名称：" + System.Configuration.ConfigurationSettings.AppSettings["UnitRoot"];
                    }
                    else if (Request.QueryString["Action"].ToString() == "SELECT")
                    {
                        worksheet.Cells[2, 2] = "单位名称：" + new BLL.Union().GetModel(Convert.ToInt32(this.Session["UnionSelect"])).单位名称; ;
                    }
                    worksheet.Cells[2, 6] = "周期 5 年 起始年份：" + theCondationDate.ToString() + "～" + (theCondationDate + 4).ToString() + "";
                    //插入格式   在第5行插入复制行
                    ((Range)(worksheet.Rows[5, System.Type.Missing])).Copy(System.Type.Missing);
                    for (int intIndex = 0; intIndex < dtSource.Rows.Count; intIndex++)
                    {
                        ((Range)(worksheet.Cells[5, 1])).EntireRow.Insert(1, System.Type.Missing);
                    }
                    //给报表赋值



                    for (int intIndex = 5; intIndex < dtSource.Rows.Count + 5; intIndex++)
                    {
                        //行(B3到I3) 内容从第3行开始
                        //序号  B⇒2	
                        worksheet.Cells[intIndex, 2] = intIndex - 4;
                        //单位	C⇒3
                        worksheet.Cells[intIndex, 3] = dtSource.Rows[intIndex - 5]["姓名"].ToString();
                        //届数	D⇒4
                        worksheet.Cells[intIndex, 4] = dtSource.Rows[intIndex - 5]["参加工作时间"].ToString();
                        //主席	E⇒5
                        worksheet.Cells[intIndex, 5] = dtSource.Rows[intIndex - 5]["享受标准"].ToString();
                        //副主席 F⇒6
                        worksheet.Cells[intIndex, 6] = dtSource.Rows[intIndex - 5]["疗养时间"].ToString();
                        //委员名称 G⇒7	
                        worksheet.Cells[intIndex, 7] = dtSource.Rows[intIndex - 5]["备注"].ToString();

                    }

                    break;

            }


            string tick = DateTime.Now.Ticks.ToString();
            string strFileName = tick + ".xls";
            string strSavePath = template_path + "\\" + strFileName;

            workbook.SaveAs(strSavePath, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

            excelOperate.Dispose(worksheet, workbook, app);//关闭Excel进程

            Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(strFileName));
            Response.ContentType = "application/ms-excel";// 指定返回的是一个不能被客户端读取的流，必须被下载
            Response.WriteFile(strFileName); // 把文件流发送到客户端
            Response.End();
        }

        public string GetTotal(object a1, object a2, object a3, object a4, object a5)
        {
            int total = 0;
            if (a1.ToString() != "")
            {
                total += Convert.ToInt32(a1);
            }
            if (a2.ToString() != "")
            {
                total += Convert.ToInt32(a2);
            }
            if (a3.ToString() != "")
            {
                total += Convert.ToInt32(a3);
            }
            if (a4.ToString() != "")
            {
                total += Convert.ToInt32(a4);
            }
            if (a5.ToString() != "")
            {
                total += Convert.ToInt32(a5);
            }

            if (total == 0)
            {
                return "";
            }
            else
            {
                return total.ToString();
            }
        }

        public string ConvertToData(object O)
        {
            if (O.ToString() != "")
            {
                return O.ToString();
            }
            return "";
        }

        public string GetPercent(object o)
        {
            string str = ConvertToData(o);
            if (str != "")
            {
                return str += "%";
            }
            return "";
        }
    }
}
